<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>我的收货地址_乐拍客</title>
  <#include "top.html">
<div class="wrap">
<div class="box">
<div class="content">
<div class="container980">
<script type="text/javascript" src="${base}/res/front/js/pcasunzip.js"></script>
<script type="text/javascript">
$(function(){
	$('#submit').click(function(){
		if($.trim($('#username').val()) == ''){
			alert('收货人不能为空');
			$('#username').focus();
			return false;
		}
		else if($.trim($('#telphone').val()) == ''){
			alert('联系电话不能为空');
			return false;
		}
		else if($.trim($('#address').val()) == ''){
			alert('收货地址不能为空');
			return false;
		}
		else{
			$.ajax({
			    type: 'post',
		        dataType: 'json',
		        data :{'reciver':$.trim($('#username').val()),
					'address':$.trim($('#address').val()),
					'postcode':$.trim($('#postcode').val()),
					'phoneno':$.trim($('#telphone').val())},
		        url: site_root+'/member/address_insert.htm',
		        cache : false,
		        error: function(){
		            alert('系统繁忙，请稍后再试');   
		        },
		        success: function(data){
		        if(data.status=='success'){
		       		alert(data.message);
		           	window.location.href=site_root+"/member/addresslist.htm";
		        }else{
		           alert(data.message);
		        }
		         return ;
		        }
		    });
			
			
		}
	});
});

</script>



<#include "userleft.html">
<div class="mem_right">
    	
<#include "userinfo.html">

<ul class="bidinfo_nav mar10">
	<li class="other"><a href="${base}/member/addresslist.htm" ><span>收货地址</span></a></li>
    <li class="thisclass"><a href="${base}/member/addressinsert.htm" ><span>添加地址</span></a></li>
	</ul>	
	<div class="editdatil mem_borD6">
		<table   style="width:736px";  cellpadding="1" cellspacing="1" >
			<tr>
				<th width="100px" height="40px" align="right">收货人：<strong class="red">*</strong></th>
				<td width="636px">
				<input type="text" class="username_required" id="username" name="reciver" maxlength="10" value=""  /><span id="username_message" class="red"></span>		
				</td>
			</tr>
			<tr >
				<th align="right">联系电话：<strong class="red">*</strong></th>
				<td>
				<input type="text" class="telphone_required" id="telphone" name="phoneno" value="" maxlength="32"  /><span id="telphone_message" class="red" ></span>
				</td>
		</tr>
		<tr>
			<th align="right"  width="100">收货地址：<strong class="red">*</strong></th>
			<td>
			<textarea name="address" id="address" class="login_input address_required" style="height:100px; width: 300px;color:#333; padding:3px 2px;font-size:13px;"></textarea>
			<span id="address_message" class="red" ></span>
		</td>
	</tr>	
	<tr>
		<th align="right" width="100">邮政编码：</th>
		<td  >
		<input type="text" id="postcode" name="postcode" value="" maxlength="6"   />
			 <span class="">有助于快速确定送货地址</span>
			</td>
	</tr>
	<tr>
			<td></td>
			<td><input id="submit" type="submit" value="确定"	 class="layer_button" />
			<input type="reset" id="btn_reset" value="重 置"  class="layer_button" />
			</td> 
	</tr>
</table>
	</div>
	
	</div>
<div class="clear"></div>
</div>
<script type="text/javascript">
	$(function(){
		$('form :input').blur(function(){
			 //验证用户名
			 if( $(this).is('.username_required') ){
				if( $.trim(this.value)==""){
					$('#username_message').text("请填写真实姓名"); 
				}else if(this.value.length>15){
					$('#username_message').text("真实姓名不得超过15个字符");
				}else{
					$('#username_message').remove();
				}
			}

			 if( $(this).is('.telphone_required') ){
				if( $.trim(this.value)==""){
					$('#telphone_message').text("请填写电话").addClass('onError'); 
				}else{
					$('#telphone_message').remove().removeClass('onError');
				}
			}

			 if( $(this).is('.address_required') ){
				if( $.trim(this.value)==""){
					$('#address_message').text("请填写地址").addClass('onError');
				}else if( this.value.length>255){
					$('#address_message').text("地址长度不得超过255字符").addClass('onError');
				}else{
					$('#address_message').remove();
				}
			}
		}).keyup(function(){
		   $(this).triggerHandler("blur");
		}).focus(function(){
	  	   $(this).triggerHandler("blur");
		});//end blur


		//提交，最终验证。
		$('#submit').click(function(){
			var userName = $("#username");
			var userNameMsg = $("#username_message");
			if(userName.val()==""){
				userNameMsg.html("收人姓名不能为空");
			}else{
				userNameMsg.html("");
			}	


			var telphone = $("#telphone");
			var telphoneMsg = $("#telphone_message");
			if(telphone.val()==""){
				telphoneMsg.html("联系电话不能为空");
			}else{
				telphoneMsg.html("");
			}

			var address = $("#address");
			var addressMsg = $("#address_message");
		
			if(address.val()==""){
				addressMsg.html("收货地址不能为空");
			}else{
				addressMsg.html("");
			}		
			
			if(userName.val()=="" || telphone.val()=='' || address.val()=='' ){
				return false;
			}else{
				return true;
				
			}
		});	
	});

	</script>
</div>
</div>
</div>
<!--底部-->
<br/>
<#include "foot.html">

</body>
</html>
<!--/底部-->